<?php
   include('./library/conn.php');

   $username=$_REQUEST['username'];
   $password=$_REQUEST['password'];

   $sql = "select * from user where username = '$username' and password='$password'";
   $sql2 = "select * from user where email = '$username' and password='$password'";
   $sql3 = "select * from user where phonenum = $username and password='$password'";

   $res = $conn->query($sql);
   $res2 = $conn->query($sql2);
   $res3 = $conn->query($sql3);

   $conn->close();
   
   if($res->num_rows>0){
      $row = $res->fetch_assoc();
      $json = json_encode($row);
      echo $json;
      die();
   }
   
   if($res2->num_rows>0){
      $row = $res2->fetch_assoc();
      $json = json_encode($row);
      $bool=true;
      echo $json;
      die();
   }

   if($res3->num_rows>0){
      $row = $res3->fetch_assoc();
      $json = json_encode($row);
      echo $json;
      die();
   }
   echo '<script>alert("用户名或密码错误！登录失败")</script>';
?>